package com.zc.operator.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.zc.operator.domain.ChargeStationPriceType;
import com.zc.operator.service.IChargeStationPriceTypeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 价格类型Controller
 * 
 * @author glb
 * @date 2023-05-25
 */
@RestController
@RequestMapping("/operator/priceType")
public class ChargeStationPriceTypeController extends BaseController
{
    @Autowired
    private IChargeStationPriceTypeService chargeStationPriceTypeService;

    /**
     * 查询价格类型列表
     */
    @PreAuthorize("@ss.hasPermi('operator:priceType:list')")
    @GetMapping("/list")
    public TableDataInfo list(ChargeStationPriceType chargeStationPriceType)
    {
        startPage();
        List<ChargeStationPriceType> list = chargeStationPriceTypeService.selectChargeStationPriceTypeList(chargeStationPriceType);
        return getDataTable(list);
    }

    /**
     * 导出价格类型列表
     */
    @PreAuthorize("@ss.hasPermi('operator:priceType:export')")
    @Log(title = "价格类型", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ChargeStationPriceType chargeStationPriceType)
    {
        List<ChargeStationPriceType> list = chargeStationPriceTypeService.selectChargeStationPriceTypeList(chargeStationPriceType);
        ExcelUtil<ChargeStationPriceType> util = new ExcelUtil<>(ChargeStationPriceType.class);
        util.exportExcel(response, list, "价格类型数据");
    }

    /**
     * 获取价格类型详细信息
     */
    @PreAuthorize("@ss.hasPermi('operator:priceType:query')")
    @GetMapping(value = "/{priceTypeId}")
    public AjaxResult getInfo(@PathVariable("priceTypeId") Long priceTypeId)
    {
        return AjaxResult.success(chargeStationPriceTypeService.selectChargeStationPriceTypeByPriceTypeId(priceTypeId));
    }

    /**
     * 新增价格类型
     */
    @PreAuthorize("@ss.hasPermi('operator:priceType:add')")
    @Log(title = "价格类型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ChargeStationPriceType chargeStationPriceType)
    {
        return toAjax(chargeStationPriceTypeService.insertChargeStationPriceType(chargeStationPriceType));
    }

    /**
     * 修改价格类型
     */
    @PreAuthorize("@ss.hasPermi('operator:priceType:edit')")
    @Log(title = "价格类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ChargeStationPriceType chargeStationPriceType)
    {
        return toAjax(chargeStationPriceTypeService.updateChargeStationPriceType(chargeStationPriceType));
    }

    /**
     * 删除价格类型
     */
    @PreAuthorize("@ss.hasPermi('operator:priceType:remove')")
    @Log(title = "价格类型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{priceTypeIds}")
    public AjaxResult remove(@PathVariable Long[] priceTypeIds)
    {
        return toAjax(chargeStationPriceTypeService.deleteChargeStationPriceTypeByPriceTypeIds(priceTypeIds));
    }
}
